# utils/io_utils.py

import os
import glob
import pandas as pd

def concat_csv_files(directory):
    all_files = glob.glob(os.path.join(directory, "*.csv"))
    df_list = []
    for f in sorted(all_files):
        try:
            df = pd.read_csv(f, encoding='utf-8')
        except:
            df = pd.read_csv(f, encoding='gbk')
        df_list.append(df)
    return pd.concat(df_list, ignore_index=True)
